package com.googlecode.gingerman.robot;

import java.util.List;
import ui.Paintable;

import com.googlecode.gingerman.world.World;
import com.googlecode.gingerman.world.geometry.Circle;
import com.googlecode.gingerman.world.geometry.Coordinates;

public class Robot implements AIRobot, Paintable {

	private Chassis chassis;
	private Locator locator;
	private Weapon weapon;
	private Health ghealth;
	private World world;
	private SimpleAI AI;
	private int health, idCmd;

	public Robot(int health, int idCmd, World world) {
		this.health = health;
		this.idCmd = idCmd;
		this.world=world;
	}

	public void makeDamage() {
		health--;
		if (health == 0) {
			world.addRobotDel(this);
			world.getRobots().remove(this);
		}
	}

	public void setSimpleAI(SimpleAI AI){
		this.AI = AI;
	}
	
	public void setChassis(Chassis chassis) {
		this.chassis = chassis;
	}
	
	public void setLocator(Locator locator) {
		this.locator = locator;
	}
	
	public void setWeapon(Weapon weapon) {
		this.weapon = weapon;
	}

	public void setWorld(World world) {
		this.world = world;
	}
	
	public World getWorld() {
		return world;
	}

	public int getIDCmd() {
		return idCmd;
	}
	
	public int getHealth() {
		return health;
	}
	
	public void setGhealth(Health ghealth){
		this.ghealth=ghealth;
	}
	
	public Health getGhealth(){
		return ghealth;
	}
	
	public Circle getCircle() {
		Coordinates coordinates = new Coordinates(chassis.getX(), chassis.getY());
		return new Circle(coordinates, chassis.getRadius());
	}

	public void step() {
		AI.step();
		chassis.step();
		weapon.step();
	}

	public double getAngle() {
		return locator.getAngle();
	}
	
	public double getX() {
		return chassis.getX();
	}

	public double getY() {
		return chassis.getY();
	}
	
	public double getRadius() {
		return chassis.getRadius();
	}

	public List<Paintable> getPaintableChildren() {
		return null;
	}

	public String getView() {
		if (idCmd==0) return "robot1";
		else return "robot2";
	}

}